package com.wh.base.sys.roleMenu.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wh.base.sys.roleMenu.entity.RoleMenu;
import com.wh.base.sys.roleMenu.mapper.RoleMenuMapper;
import com.wh.base.sys.roleMenu.service.RoleMenuService;

/**
 * <p>
 * 角色与权限关联 服务实现类
 * </p>
 *
 * @author WangHong
 * @since 2022-05-06
 */
@Service
public class RoleMenuServiceImpl extends ServiceImpl<RoleMenuMapper, RoleMenu> implements RoleMenuService {

	@Override
	public Map<String, Boolean> getRoleMenuToMap(Long id) {
		QueryWrapper<RoleMenu> rmWrapper = new QueryWrapper<RoleMenu>();
		rmWrapper.eq("role_id", id);
		List<RoleMenu> rmList = list(rmWrapper);
		Map<String, Boolean> map = new HashMap<String, Boolean>();
		if(rmList != null && rmList.size() > 0) {
			for(RoleMenu rm : rmList) {
				map.put(String.valueOf(rm.getMenuId()), true);
			}
		}
		return map;
	}
	
}
